﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using PromotionApp.Model;

namespace PromotionApp.UserControl
{
    public partial class ucMenu : System.Web.UI.UserControl
    {
        #region Private Method

        private string GetCurrentClass(string strUrl)
        {
            return this.Request.RawUrl.IndexOf(strUrl) != -1 ? "class='current'" : "";
        }        
        
        #endregion

        #region Event

        protected void Page_Load(object sender, EventArgs e)
        {            
        }

        #endregion   
     
        #region Public Method

        public void Initialize(UserRole userRole)
        {
            StringBuilder sb = new StringBuilder();            

            sb.AppendFormat("<li {0}><a href='Search.aspx'>Search</a></li>", GetCurrentClass("Search"));            

            if (userRole == UserRole.Administrator_Enabled)
            {
                sb.AppendFormat("<li {0}><a href='CategoryMaster.aspx'>Category</a></li>", GetCurrentClass("Category"));
                sb.AppendFormat("<li {0}><a href='InternalUserMaster.aspx'>InternalUser</a></li>", GetCurrentClass("InternalUser"));
            }

            this.litMenu.Text = sb.ToString();
        }

        #endregion
    }
}